package com.dnjn.happiness.emo.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dnjn.happiness.emo.domain.EmoTeamAvgScoreHistory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 团队历史每日平均值 留180天数据?Mapper接口
 *
 * @author happiness
 * @date 2023-10-28
 */
public interface EmoTeamAvgScoreHistoryMapper extends BaseMapper<EmoTeamAvgScoreHistory> {

    @Select(" SELECT h.avg_score,h.curr_date currDate,h.dept_id FROM emo_team_avg_score_history h WHERE h.curr_date BETWEEN #{startTime} AND #{endTime} AND h.dept_id = #{deptId} ORDER BY h.curr_date ")
    List<EmoTeamAvgScoreHistory> currenDeptHistoryAvgScore(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("deptId") Long deptId);

    @Delete(" DELETE FROM emo_team_avg_score_history WHERE curr_date <= #{delFlag} ")
    void deleteHistoryByDaysAgo(String delFlag);
}
